package py.com.erpone.session.dm.list;

import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import py.com.erpone.entity.dm.Ciudad;
import py.com.erpone.entity.dm.Division;
import py.com.erpone.entity.dm.Pais;
import py.com.erpone.entity.dm.Sector;
import py.com.erpone.entity.dm.SectorDivision;



@Stateless
@LocalBean
@Named
public class DivisionList {
	
	@PersistenceContext
	private EntityManager em;
	
	
	@SuppressWarnings("unchecked")
	public List<SectorDivision> findAll(){   
		List<SectorDivision> result=(List<SectorDivision>)em.createNamedQuery("divisiones.all").getResultList();
		return result;
	}
	@SuppressWarnings("unchecked")
	public List<SectorDivision> findAllDivisionBySector(Sector sector){
		List<SectorDivision> result=(List<SectorDivision>)em.createNamedQuery("divisionesBySector.all").setParameter("sector", sector).getResultList();
		return result;
	}
	public SectorDivision findById(Long id){ 
		return em.find(SectorDivision.class, id);
	}
	
	
}
